/*
 * Copyright (c) Huawei Technologies Co., Ltd. 2018-2019.
 * Description: support linux run in nonsec mode in cortex A15
 * Author: xiaowei <xiaowei774@huawei.com>
 * Create: 2018-09-17
 */

#ifndef UNCOMPRESS_H_BE8_COMPATIBLE
#define UNCOMPRESS_H_BE8_COMPATIBLE

#ifdef CONFIG_CPU_ENDIAN_BE8
static inline __attribute_const__ __u32 __hisi_swab32(__u32 x)
{
	__asm__ ("rev %0, %1" : "=r" (x) : "r" (x));
	return x;
}

#define cpu_to_le32_hisi(x)	(__hisi_swab32((x)))
#else
#define cpu_to_le32_hisi(x)	((__u32)(x))
#endif

#define io_write(addr, val) (*(volatile unsigned int *)(uintptr_t)(addr) = (cpu_to_le32_hisi(val)))
#define IO_READ(addr, val) ((val) = cpu_to_le32_hisi(*(volatile unsigned int *)(uintptr_t)(addr)))

#endif
